<?xml version='1.0' encoding='iso-8859-1'?>
<!doctype html public '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
<html xmlns='http://www.w3c.org/1999/xhtml' lang='en-us'>
	<head>
		<title>
			tr069prog.sh
			</title>
		<meta http-equiv='content-type' content='text/html;iso-8859-1'/>
		<meta name='generator' content='motley-tools 1.9.4 13:40:33 Feb 18 2015'/>
		<meta name='author' content='cmaier@cmassoc.net'/>
		<meta name='robots' content='noindex,nofollow'/>
		<link href='toolkit.css' rel='stylesheet' type='text/css'/>
		</head>
	<body>
		<div class='headerlink'>
			[<a href='start.sh.html' title=' start.sh '>PREV</a>]
			[<a href='toolkit.html' title=' Index '>HOME</a>]
			[<a href='traffic.sh.html' title=' traffic.sh '>NEXT</a>]
			</div>
<pre>
#!/bin/sh
# file: tr069prog.sh

# ====================================================================
#
# This script programs a unique TR-069 ACS Username and ACS Password 
# into a INT6400 powerline device and updates the Mfg feed file; 
# the original MAC, DAK and NMK are preserved; the MFG, NET and USR
# HFIDs are set to the values defined in this file; the ACS Username
# is derived from the original MAC; the ACS Password is derived from
# the local host random number generator;
#
# devices should be programmed and tested using the PTS then updated
# using his script; Atheros Powerline Toolkit 1.3.1 is needed;
#
# --------------------------------------------------------------------

#
# Define environment;
#

ETH=eth0                # PC ethernet port 
NVMFILE=tr069.nvm       # This is the NVM file to program
REFPIB=tr069.pib        # This is the PIB template to use
PIBFILE=tmp.pib         # Temp PIB to modify
MFGFILE=mfgfeed.txt     # Manufacturing Feed File

#
# Determine device identity;
#

MAC=$(int6kid -Ai ${ETH})
DAK=$(int6kid -Di ${ETH})
NMK=$(int6kid -Mi ${ETH})

#
# Define default HFIDs;
#

MFG=&quot;MANUFACTURER MODEL-AB-02-01&quot;
NET=&quot;MANUFACTURER MODEL-AB-02-01&quot;
USR=&quot;MANUFACTURER MODEL-AB-02-01&quot;

#
# Make a copy of PIB to edit
#

cp ${REFPIB} ${PIBFILE}

#
# Set MAC, DAK, NMK, MFG_HFID, NET_HFID and USR_HFID in PIB file
#

modpib ${PIBFILE} -M ${MAC} -D ${DAK} -N ${NMK} -S &quot;${MFG}&quot; -T &quot;${NET}&quot; -U &quot;${USR}&quot; 

UMAC=$(echo $MAC | sed 'y/abcdef/ABCDEF/' | sed 's/://g' | sed 's/ //g') 
OUI=$(echo $UMAC | cut -c 1-6)

#
# Build the ACS Username
#

UNAME=&quot;$OUI&quot;-&quot;$UMAC&quot;

#
# Generate a 16 character lower case random ACS password
#

RANDOMPWORD=$(&lt;/dev/urandom tr -dc a-z0-9| (head -c $1 &gt; /dev/null 2&gt;&amp;1 || head -c 16))

#
# Set Username and Password in PIB file
#

setpib ${PIBFILE} 2DCC username ${UNAME}
setpib ${PIBFILE} 2ECD password ${RANDOMPWORD}
setpib ${PIBFILE} 2FCE byte 01

#
# Write NVM and PIB
#

int6kp -i ${ETH} -P ${PIBFILE} -N ${NVMFILE} -FF -D ${DAK}
FW=$(int6k -qri ${ETH} | rev | cut -d &quot; &quot; -f1 | rev)

#
# Write the record to Mfg feed file
#

echo $UMAC&quot;|&quot;$FW&quot;|&quot;$RANDOMPWORD&quot;|1.0|&quot;$RANDOMPWORD&quot;|000000&quot; &gt;&gt; ${MFGFILE}


</pre>
		<div class='footerlink'>
			[<a href='start.sh.html' title=' start.sh '>PREV</a>]
			[<a href='toolkit.html' title=' Index '>HOME</a>]
			[<a href='traffic.sh.html' title=' traffic.sh '>NEXT</a>]
			</div>
		</body>
	</html>
